package com.example.yunJie.digitalSentry.service.impl;

import com.example.yunJie.digitalSentry.entity.RecognitionEntity;
import com.example.yunJie.digitalSentry.mapper.one.RecognitionMapper;
import com.example.yunJie.digitalSentry.service.RecognitionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.List;

@RequiredArgsConstructor
@Service
public class RecognitionServiceImpl implements RecognitionService {


    private final RecognitionMapper recognitionMapper;


    @Override
    public int insert(RecognitionEntity recognitionEntity) {
        Date date = new Date(Long.parseLong(recognitionEntity.getCapture_time()));
        SimpleDateFormat sdf1= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf1.format(date);
        recognitionEntity.setCapture_time(format);
        return recognitionMapper.insert(recognitionEntity);
    }

    @Override
    public int update(RecognitionEntity recognitionEntity) {
        return recognitionMapper.update(recognitionEntity);
    }

    @Override
    public int deleteById(Serializable id) {
        return recognitionMapper.deleteById(id);
    }

    @Override
    public int deleteIdList(List<Integer> idList) {
        return recognitionMapper.deleteIdList(idList);
    }

    @Override
    public RecognitionEntity findId(Serializable id) {
        return recognitionMapper.findId(id);
    }

    @Override
    public List<RecognitionEntity> findAll() {
        return recognitionMapper.findAll();
    }

    @Override
    public List<RecognitionEntity> findAllByCapture_time(String s) {
        return recognitionMapper.findAllByCapture_time(s);
    }
}
